package com.tools.module.base.web;

import com.tools.common.config.AbstractController;
import com.tools.common.model.Result;
import com.tools.common.util.DateUtils;
import com.tools.common.util.ShiroUtils;
import com.tools.module.base.entity.BaseBid;
import com.tools.module.base.service.BaseBidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/base/bid")
public class BaseBidController extends AbstractController {

    @Autowired
    private BaseBidService bidService;

    /**
     * 列表
     */
    @PostMapping("/list")
    public Result list(BaseBid bid){
        return bidService.list(bid);
    }
    /**
     * 查询
     */
    @PostMapping("/get")
    public Result get(Long id){
        return bidService.get(id);
    }
    /**
     * 保存
     */
    @PostMapping("/save")
    public Result save(@RequestBody BaseBid bid){
        if (bid.getId()==null){
            bid.setCreateTime(DateUtils.getTimestamp());
            bid.setCreateUid(ShiroUtils.getUserId());
        }
        bid.setUpdateUid(ShiroUtils.getUserId());
        return bidService.save(bid);
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public Result delete(Long id){
        return bidService.delete(id);
    }
}
